﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using eProject_SEM3_SecurityServices.DataAccess;
using eProject_SEM3_SecurityServices.ObjectClass;
using System.Data;
using System.Data.SqlClient;

namespace eProject_SEM3_SecurityServices.Bussiness
{
    public class BCustomer
    {
        DCustomer dcustomer = null;

        public BCustomer()
        {
            dcustomer = new DCustomer();
        }

        public List<OCustomer> getCustomerList()
        {
            List<OCustomer> listCustomer = null;
            if (dcustomer.getCustomerList().Rows.Count > 0)
            {
                listCustomer = new List<OCustomer>();

                foreach (DataRow row in dcustomer.getCustomerList().Rows)
                {
                    OCustomer customer = new OCustomer();
                    customer.CustomerID = Convert.ToInt32(row["customerId"]);
                    customer.CustomerName = row["customerName"].ToString();
                    customer.CustomerAddress = row["customerAddress"].ToString();
                    customer.CustomerPhone = row["customerPhone"].ToString();

                    listCustomer.Add(customer);
                }
            }
            return listCustomer;
        }
        //@cusId int
        public OCustomer GetCustomerDetails(int cusId)
        {
            return dcustomer.getCustomerDetails(cusId);
        }

        /*@customerId int,
            @customerName nvarchar(250),
            @customerPhone nvarchar(250),
            @customerAddress nvarchar(250)*/
        public bool UpdateCustomer(OCustomer customer)
        {
            return dcustomer.UpdateCustomer(customer);
        }

        /*@customerName nvarchar(250),
            @customerPhone nvarchar(250),
            @customerAddress nvarchar(250*/
        public bool AddCustomer(OCustomer customer)
        {
            return dcustomer.AddCustomer(customer);
        }
        //@customerId int
        public bool DeleteCustomer(int customerId)
        {
            return dcustomer.DeleteCustomer(customerId);
        }
    }
}